<extend name="./public/frame.html"/>
<block name="content">
    <form class="layui-form" action="{:url('submits')}" method="post">
        <!--<input type="hidden" name="k_id" value="{$k_config['id']}"/>-->
        <!--<input type="hidden" name="s_id" value="{$s_config['id']}"/>-->
        <table class="layui-table">
            <tr>
                <td colspan="2">
                    <table class="layui-table" style="width: 50%">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8;" colspan="2">
                                <input type="text" class="layui-input" readonly value="
快车[实时订单]派单设置" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="" style="text-align: center;">推送时间间隔( 秒 )</div>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="text" name="s_push_time_interval" lay-verify="required|number" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" autocomplete="off" class="layui-input" value="{$s_info['push_time_interval']}">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="" style="text-align: center;">轮询时间间隔( 分钟 )</div>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="text" name="s_polling_time_interval" lay-verify="required|number" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" autocomplete="off" class="layui-input" value="{$s_info['polling_time_interval']}">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="" style="text-align: center;">订单超时关闭时间( 分钟 )</div>
                            </td>
                            <td>
                                <div class="layui-input-inline">
                                    <input type="text" name="s_order_time_out" lay-verify="required|number" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" autocomplete="off" class="layui-input" value="{$s_info['order_time_out']}">
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <table class="layui-table" style="width: 50%">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="3">
                                <input type="text" class="layui-input" readonly value="
快车[预约订单]派单设置" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="" style="text-align: center;">轮询时间间隔( 分钟 )</div>
                            </td>
                            <td>
                                <table id="tbl1">
                                </table>
                            </td>
                            <td>
                                <i class="layui-icon"><input type="button" class="button layui-btn layui-btn-sm" value="&#xe654;新增" onclick="addByScript()"/></i>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <button class="layui-btn" lay-submit="submit" lay-filter="submit">提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>

        <input type="hidden" value="{$y_polling_count}" name="" id="polling_time">

        <!--<for start="0" end="$polling_time_count">-->
            <!--<input type="text" name="polling_time_{$i}" value="{$y_polling[$i]}" />-->
        <!--</for>-->
        <volist name="$y_polling" id="item">
            <input type="hidden" name="polling_time_{$key}" value="{$item}" />
        </volist>
    </form>
    <script>
        layui.use(['form', 'upload'], function(){
            var form = layui.form
                ,layer = layui.layer;
        });
        var count = 0;
        var polling_time_count = $("#polling_time").val();
        if(polling_time_count > 0) {
            for(i=0;i<polling_time_count;i++) {
                addByScript();
                polling_time = $("input[name='polling_time_" + i + "']").val();
                $("input[name='y_polling_time_" + i + "']").val(polling_time);
            }
        }

        function addByScript() {
            var table = document.getElementById("tbl1");
            var newRow = table.insertRow(table.rows.length);
            newRow.id = "row" + count;

            var contentCell = newRow.insertCell(-1);
            contentCell.innerHTML = '<input name="y_polling_time_'+ count + '" type="text" value="" class="layui-input start_time"' +
                ' lay-verify="required|number" autocomplete="off" onkeyup="value=value.replace(/^(0+)|[^\\d]+/g,\'\')"/>';

            contentCell = newRow.insertCell(-1);

            var delBtn = document.createElement("input");
            delBtn.type = "button";
            delBtn.className = "button layui-btn layui-btn-sm layui-icon";
            delBtn.id = "btnDel"+count;
            delBtn.value = "- 删除";
            delBtn.onclick = new Function("del(this)");
            contentCell.appendChild(delBtn);

            count++;
        }

        function del(obj) {
            var row = obj.parentNode.parentNode;
            row.parentNode.removeChild(row);
        }

    </script>
</block>